package dk.dashboardFP.panels.displayPanel {
	import dk.dashboardFP.dfpLogger.DFPLogger;
	import dk.dashboardFP.utils.describeObjectUtil.DescribeObjectUtil;

	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	/**
	 * @author josef
	 */
	public class SelectionListItem extends Sprite {
		private var _item : DisplayObject;
		private var _button : SelectionListButton;
		private var _inspectChainButton : ListShortCutButton;
		private var _inspectDCButton : ListShortCutButton;

		public function SelectionListItem(item : DisplayObject) {
			_item = item;
			setupElements();
		}

		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// setup
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

		private function setupElements() : void {
			
			//:::::::
			// button 
			_button = new SelectionListButton(_item);
			addChild(_button);
			
			//:::::::
			// shortcuts 
			_inspectChainButton = new ListShortCutButton(4);
			addChild(_inspectChainButton);
			
			_inspectChainButton.x = _button.width + 10;
			_inspectChainButton.y = 7;
			
			_inspectChainButton.addEventListener(MouseEvent.MOUSE_UP, onInspectChainUp, false, 0, true);
			
			//:::::::
			// bla 
			_inspectDCButton = new ListShortCutButton(3);
			addChild(_inspectDCButton);
			
			_inspectDCButton.x = _inspectChainButton.x + 15;
			_inspectDCButton.y = 7;
			
			_inspectDCButton.addEventListener(MouseEvent.MOUSE_UP, onInspectDCUp, false, 0, true);
		}

		private function onInspectChainUp(event : MouseEvent) : void {
			DFPLogger.inspectDisplayChain(DescribeObjectUtil.getObjectDescription(_item).className, _item, -1, "", true, 0);
		}

		private function onInspectDCUp(event : MouseEvent) : void {
			DFPLogger.inspect(DescribeObjectUtil.getObjectDescription(_item).className, _item, -1, "", true);
		}

		public function get item() : DisplayObject {
			return _item;
		}

		public function get inspectChainButton() : ListShortCutButton {
			return _inspectChainButton;
		}

		public function get button() : SelectionListButton {
			return _button;
		}
	}
}
